# -*- coding: utf-8 -*-
"""
    @Author：SimpleTree
    @date：2025/4/26 10:53
    @desc:
"""
import os


def singleton(cls, *args, **kw):
    """
    Singleton decorator
    """
    instance = {}
    def _singleton():
        key = str(cls) + str(os.getpid())
        if key not in instance:
            instance[key] = cls(*args, **kw)
        return instance[key]
    return _singleton